using Windows.UI;

namespace MultiAgentsClient.Presentation;

public class ColorHelpers
{
    private static Color ColorFromHex(string hex)
    {
        // Remove the # at the front if it's there
        hex = hex.Replace("#", string.Empty);

        byte a = 255, r, g, b;
        int start = 0;

        // Handle ARGB strings (8 characters long)
        if (hex.Length == 8)
        {
            a = byte.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
            start = 2;
        }

        // Handle RGB strings (6 characters long)
        r = byte.Parse(hex.Substring(start, 2), System.Globalization.NumberStyles.HexNumber);
        g = byte.Parse(hex.Substring(start + 2, 2), System.Globalization.NumberStyles.HexNumber);
        b = byte.Parse(hex.Substring(start + 4, 2), System.Globalization.NumberStyles.HexNumber);

        return Color.FromArgb(a, r, g, b);
    }

    public static Brush MentionableBackground = new SolidColorBrush(ColorFromHex("#ffffff"));
    public static Brush MentionableBackgroundHighlight = new SolidColorBrush(ColorFromHex("#edeeee"));
    public static Brush ChatRoomBackground = new SolidColorBrush(ColorFromHex("#fcfcfc"));
    public static Brush ChatRoomBackgroundHighlight = new SolidColorBrush(ColorFromHex("#e3edfc"));


    public static Brush GreenTxtBgd = new SolidColorBrush(ColorFromHex("#D1E3FF"));
    public static Brush WhiteTxtBgd = new SolidColorBrush(ColorFromHex("#EBECED"));
    public static Brush ToolResultBgd = new SolidColorBrush(ColorFromHex("#E3D7F5"));
    public static Brush ToolResultBorderClr = new SolidColorBrush(ColorFromHex("#D7C2F6"));
    public static SolidColorBrush ChatAreaBgd = new SolidColorBrush(ColorFromHex("#f5f5f5"));
    public static Brush ChatAreaSepLine = new SolidColorBrush(ColorFromHex("#ececec"));
    public static Brush BlackBrush = new SolidColorBrush(Colors.Black);
    public static Brush ProjectAreaBgd = new SolidColorBrush(ColorFromHex("#e9e8e8"));
    public static Color ProjectSelectedClr = ColorFromHex("#c8c6c6");
    public static Brush ProjectAreaHeaderBgd = new SolidColorBrush(ColorFromHex("#f7f7f7"));
    public static Brush InputAreaSendButton = new SolidColorBrush(ColorFromHex("#e9e9e9"));
    public static Brush InputAreaSendButtonTxtClr = new SolidColorBrush(ColorFromHex("#1bc46c"));

    public static string WebviewAuthorFontBrush => "#aaaaaa";
    public static string WebviewMessageFontBrush => "#333333";
    public static string WebviewUserMegTxtBgd => "#D1E3FF";
    public static string WebviewAssitantMegTxtBgd => "#EBECED";
    public static string WebviewToolMegTxtBgd => "#E3D7F5";
}
